<?php
namespace App\Http\Controllers;

use App\Helpers\SearchService;
use App\Models\Company;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
class Company1Controller1 extends CommonController
{
    // 示例方法，用于展示后台首页
    public function getlist(Request $request)
    {

        $page = $request->input('page',1);
        $limit = $request->input('limit',10);
        $status = $request->input('status',null);
        $name = $request->input('name',null);

        $where = [];
        if($status){
            $where[] = ['status','=',$status];
        }
        if($name){
            $where[] = ['name','like', '%'.$name.'%'];
        }

        $users = Company::where($where)->orWhere(function ($query) use ($name){
            $query->where('content', 'like', '%'.$name.'%');
        })->paginate( $limit,['*'],'page',$page);
        $data = [
            "code"=>200,
            "msg"=>"success",
            "data"=>$users->items(),
            "total"=>$users->total(),
            "limit"=>$users->perPage(),
            "page"=>$users->currentPage(),
            "last_page"=>$users->lastPage()
        ];
        if($users->total() == 0){
            return re_warning('暂无数据',null);
        }else{
            return re_success('操作成功',$data);
        }
    }
    // 其他可能的方法，如用户管理
    public function create()
    {
        // 逻辑代码
        dump('单位厂家');
    }
}
